const router = require("koa-router")();
const Mock = require("mockjs");
let { addressList } = Mock.mock({
  "addressList|100": [
    {
      id: "@id",
      name: "@cname",
      address: "@city",
      tel: /1[3-9]\d{9}/,
    },
  ],
});

router.get("/address/list", (ctx) => {
  ctx.body = {
    code: 200,
    data: addressList,
  };
});

router.delete("/address/list", (ctx) => {
  const { id } = ctx.request.query;

  addressList = addressList.filter((v) => v.id !== id);

  ctx.body = {
    code: 200,
    message: "删除成功",
  };
});

module.exports = router;
